import BaseComponent from "../../pages/BaseComponent";
import {Button, View} from "@tarojs/components";
import "./index.less";
import PickView from "../base/WPickView";

export default class TimeChoseModal extends BaseComponent {

  static defaultProps = {
    choseM: "05",
    onComfire: undefined,
    onCancell: undefined,
  };

  mValues = [];

  mClose = "00";

  componentDidMount() {
    super.componentDidMount();

    const {choseMC} = this.props;
    this.mClose = choseMC;
  }

  constructor() {
    super();

    let mValues = this.mValues;
    mValues.push("05");
    mValues.push("15");
    mValues.push("30");
    mValues.push("60");
    mValues.push("90");
  }

  onComfire = () => {
    const {onComfire} = this.props;
    if (!!onComfire) {
      onComfire(this.mClose);
    }
  }

  onCancell = () => {
    const {onCancell} = this.props;
    if (!!onCancell) {
      onCancell();
    }
  }

  render() {

    const {choseM} = this.props;

    return (
      <View className='time_chose_modal_content'>
        <View className='time_title'>延时关机</View>
        <View className='time_pick_group'>
          <View className='time_pick'>
            <PickView unit='分钟后' values={this.mValues} value={choseM} onSelect={v => this.mClose = v}/>
          </View>
        </View>

        <View className='time_chose_ops'>
          <Button className='time_chose_ok' onClick={this.onCancell}>取消</Button>
          <Button className='time_chose_ok' onClick={this.onComfire}>确定</Button>
        </View>

      </View>
    );
  }

}
